home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2010 Summer - Disc 1
/
WN_Ete2010_CD1.iso
/
Onglet5
/
Weezo
/
Weezo setup.exe
/
{code_appDir}
/
www
/
res
/
explorer
/
Photo1
/
index.php
< prev
next >
Wrap
PHP Script
|
2010-05-19
|
12KB
|
332 lines
<?php
/**
* Photo album V4
*
* Display a photo album based on files located in a given directory (and subdirs)
* Display thumbnails and preview.
* Display full size view in separate window
*
* PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category NA
* @package NA
* @author Nicolas Bruley / Peer 2 World <contact@weezo.net>
* @copyright 2005-2009 Nicolas Bruley / Peer 2 World
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
* @link http://www.weezo.net
* @since File available since Release 1.0.0
*/
require(INCLUDE_DIR.'explorerFunctions.php');
require(INCLUDE_DIR.'outputFunctions.php');
$_ENV['COMBINED_LAYOUTS']=array('20'=>2,'21'=>2,'10'=>1,'30'=>3,'31'=>3,'32'=>3,'40'=>4);
/**
* @desc Init / update (from setCombinedLayout async POST) combinedLayout propertie
*/
function initCombinedLayout(){
// Backward compatibility: set combinedLayout for Photo1 resources
if(!cfRGetVar('combinedLayout')) {
cfRSetVar('combinedLayout','10');
// and force 240px thumbnails as Photo1 thumbnails were too small for other displays
cfRSetVar('thumbnailsSize',240);
}
$prev=cfRGetVar('combinedLayout');
$new=@$_POST['setCombinedLayout'];
if(!isset($_ENV['COMBINED_LAYOUTS'][$new])) $new=$prev;
// combinedLayout updated
if($prev!==$new || !cfRGetVar('combinedLayoutInitialized')){
// Set combinedLayout
cfRSetVar('combinedLayout',$new);
$mainLayout= $new[0];
$subLayout = $new[1];
switch ($_ENV['COMBINED_LAYOUTS'][$new]){
case 1:
// Display preview image
cfRSetVar('previewDisplay',true);
// Reset thumbnails cropping and specific tooltip image size (Photo1 & Photo2)
cfRUnsetVar('cropThumbnails');
cfRUnsetVar('tooltipImageWidth');
cfRUnsetVar('tooltipImageHeight');
// Use filesLayoutResource() javascript function to async update files
cfRSetVar('filesLayout','customIcons');
// Thumbnails interval
cfRSetVar('resourceLayout','useInterval');
cfRSetVar('itemsPerPage',cfRGetVar('itemsPerPageLayout1'));
break;
case 2:
// Don't display preview image
cfRSetVar('previewDisplay',false);
if($new=='20') cfRSetVar('filesLayout','list'); else cfRSetVar('filesLayout','icons');
// Thumbnails
cfRUnsetVar('cropThumbnails');
cfRUnsetVar('tooltipImageWidth');
cfRUnsetVar('tooltipImageHeight');
// Thumbnails interval
if($new=='20'){
// List display: show all
cfRSetVar('resourceLayout','all');
}
else{
// Icons display: show only interval
cfRSetVar('resourceLayout','useInterval');
cfRSetVar('itemsPerPage',cfRGetVar('itemsPerPageLayout2'));
}
break;
case 3:
// Crop thumbnails, enlarge 150% before cropping, set specific tooltip image size
cfRSetVar('cropThumbnails',150);
cfRInitVar('tooltipImageWidth',400);
cfRInitVar('tooltipImageHeight',300);
// Set layout from subLayout (inverted values)
cfRSetVar('layout',2-$subLayout);
// Display or not the preview image (Photo3)
if(cfRGetVar('layout')>0) cfRSetVar('previewDisplay',true); else cfRSetVar('previewDisplay',false);
// Use filesLayoutResource() javascript function to async update files
cfRSetVar('filesLayout','customIcons');
// Display all Thumbnails
cfRSetVar('resourceLayout','all');
break;
case 4:
// Don't display preview image
cfRSetVar('previewDisplay',false);
// Use filesLayoutResource() javascript function to async update files
cfRSetVar('filesLayout','customIcons');
// Thumbnails
cfRUnsetVar('cropThumbnails');
cfRUnsetVar('tooltipImageWidth');
cfRUnsetVar('tooltipImageHeight');
// Icons display: show only interval
cfRSetVar('resourceLayout','useInterval');
cfRInitVar('itemsPerPageLayout4',50);
cfRSetVar('itemsPerPage',cfRGetVar('itemsPerPageLayout4'));
break;
}
cfRSetVar('combinedLayoutInitialized',1);
// If user requested a new layout, sync reload page, except if Photo2->Photo2 or Photo3->Photo3
if(isset($_POST['setCombinedLayout'])){
if($_ENV['COMBINED_LAYOUTS'][$new]!==$_ENV['COMBINED_LAYOUTS'][$prev]) {
cfAsyncHeader();
echo cfAsyncXMLJSaction('wl.goURL()');
die(cfAsyncFooter());
}
}
}
}
/**
* @desc init photo explorer
*
*/
function initPhotoExplorerData(){
if(!cfRGetVar('resourceParametersInitialized')){
cfRSetVar('extensionFilter',false); // No filter on extension
cfRSetVar('fileTypeFilter',array('image')); // Only display images
cfRSetVar('efEditMode',false);// Startup comments edit mode (false:view, true:edit)
cfRInitVar('thumbnailsIndex','0'); // index of first displayed thumbnail
cfRInitVar('activePreview',0); // index of preview image
cfRSetVar('displayMultipleDownload',true); // Display multiple download box (only if multipleDownloadAllowed)
cfRInitVar('actionsPanel',1); // Right panel unfolded
cfRInitVar('CLSShow',1); // Show combined layout selector
// Backward compatibility: new functions use thumbnailsSize instead of efThumbnailsMaxWidth
cfRInitVar('thumbnailsSize',240); // Size of generated thumbnails, and of full-size thumbnails
cfRInitVar('thumbnailsSizeFactor',2); // thumbnailsSize modifier of thumbnails: 0=>1/4, 1=>1/2, 2=>1/1
// Browser specific parameters
if(!cfBGetVar('download')) {
cfRSetVar('multipleDownloadAllowed',false);
cfRSetVar('downloadShortcut',false);
cfRSetVar('uploadAllowed',false);
}
// indicate that parameters have been initialized
if(cfRGetVar('resourceConfigured')) cfRSetVar('resourceParametersInitialized',true);
else $errorMessageCritical=cfCaption('configErrorNotConfigured');
}
// Init treeview
global $tree;
if(cfRGetVar('treeViewAvailable')){
cfRSetVar('treeViewDisplayed',true);
$tree=new treeViewFolder(cfRGetVar('treeViewAvailable'));
$tree=treeFolderLoad(cfRGetVar('treeViewAvailable'));
$tree->syncSelectPath=false;
}
else cfRSetVar('treeViewDisplayed',false);
}
/**
* @desc Insert HTML code for combinedLayout selector
*
*/
function photoCombinedLayoutSelector(){
// Set layouts icons
$current=cfRGetVar('combinedLayout');
foreach ($_ENV['COMBINED_LAYOUTS'] as $key=>$value) {
$icon=outIcon('photoLayout'.$key);
echo outBlockItem('combinedLayoutSwitch','<img src="'.$icon.'" alt="" style="width:48px;height:48px">','id="combinedLayoutSwitch'.$key.'"','margin-right:7px;margin-left:0px;padding:8px;',array('onclick'=>'setCombinedLayout(\''.$key.'\')'),(($key==$current)?'sel':'unsel'));
}
echo '<i style="margin-right:4em"> </i>';
// Set size selection icons
$current=cfRGetVar('thumbnailsSizeFactor');
foreach (array('0'=>'efTNSize480','1'=>'efTNSize481','2'=>'efTNSize482') as $key=>$value) {
$icon=outIcon($value);
echo outBlockItem('sizeFactorSwitch','<img src="'.$icon.'" alt="">',false,'margin-right:7px;margin-left:0px;padding:8px;',array('onclick'=>'sendData(\'data3=efTNSize&data4='.$key.'\')'),(($key==$current)?'sel':'unsel'));
}
}
/**
* @desc Insert frame1 DIV preview title and combinedLayout selector
*
*/
function photoHeader(){
global $preview;
echo outDivFrame('frame1');
$l=$preview->title();
$r='';
if(!cfRGetVar('filesLayoutLocked')) $r='<span style="cursor:pointer">'.outImageIcon('combinedLayout').cfCaption('genDisplay').outImage(outIcon(((cfRGetVar('CLSShow'))?'up':'down')),false,'id="CLSToggleIcon"','margin-left:0.5em;vertical-align:middle').'</span>';
echo outFrameHeaderTable('frame1Header',$l,$r,((cfRGetVar('filesLayoutLocked'))?'':'onclick="CLSToggle()"'));
echo outDivFrame('banner','id="combinedLayoutSelectorDiv"','overflow:hidden;'.((cfRGetVar('CLSShow'))?'':'height:1px;display:none'));
if(!cfRGetVar('filesLayoutLocked')) photoCombinedLayoutSelector();
echo '</div>';
}
// Init common explorer data
efInit();
$preview=new efPreview();
// Set/change active combined layout
initCombinedLayout();
// Init photo explorer data
initPhotoExplorerData();
/**
* If mobile device, redirect to mobile explorer
*/
if(cfIsMobile()) {require(INCLUDE_DIR.'mobileExplorerFunctions.php');mefExplorer();exit;}
// Reset preview image rotation
cfRUnsetVar('previewAngle');
/*
***************************************************************************************************************************
* Process POST commands
***************************************************************************************************************************
*/
efProcessPOST();
cfAsyncXMLChangePhpVarValue('displayMultipleDownload'); // process hide / show multiple download frame dynamic update
cfAsyncXMLChangePhpVarValue(SLIDESHOW_TIMER_CONTROL_NAME,array(1,2,3,4,5,10,15,30)); // process slideshow timeout value change
cfAsyncXMLChangePhpVarValue('actionsPanel'); // process hide / show right panel
cfAsyncXMLChangePhpVarValue('CLSShow',array(0,1)); // process hide / show combinedLayout Selector
if (cfRGetVar('combinedLayout')=='10') cfRSetVar('itemsPerPageLayout1',cfRGetVar('itemsPerPage')); // Update layout 1 items per page
elseif (cfRGetVar('combinedLayout')=='21') cfRSetVar('itemsPerPageLayout2',cfRGetVar('itemsPerPage')); // Update layout 2 items per page
elseif (cfRGetVar('combinedLayout')=='40') cfRSetVar('itemsPerPageLayout4',cfRGetVar('itemsPerPage')); // Update layout 4 items per page
/*
***************************************************************************************************************************
* Get files and subfolders list, generate thumbnails if needed
***************************************************************************************************************************
*/
efDirUpdate();
// If using list view or icon view and async directory selection through treeView, update files view and exit
efFilesListAsyncUpdate();
/*
***************************************************************************************************************************
* Insert HEAD, JS functions and form
***************************************************************************************************************************
*/
efInsertExplorerHeadAndBody();
?>
<script type="text/javascript">
var combinedLayout="<?php echo cfRGetVar('combinedLayout');?>";
var subLayout=<?php echo substr(cfRGetVar('combinedLayout'),-1); ?>;
var tnWidth=<?php echo efThumbnailsMaxWidth() ?>;
function CLSToggling(anim){
setAlpha(anim.item,anim.step)
winResized();
dd.recalc();
}
function CLSToggle(){
if(dgi('combinedLayoutSelectorDiv').style.display=='none'){
wl.nodeCollapseToggle('combinedLayoutSelectorDiv','CLSShow',CLSToggling)
/*
wl.fadeStyle('combinedLayoutSelectorDiv','height',72,'exponential',5,'CLSToggled()');
sendData('CLSShow=1');
fade('combinedLayoutSelectorDiv',0,1,10);
*/
dgi('CLSToggleIcon').src="<?php echo outIcon('up');?>"
}
else{
wl.nodeCollapseToggle('combinedLayoutSelectorDiv','CLSShow',CLSToggling)
/*
wl.fadeStyle('combinedLayoutSelectorDiv','height',0,'exponential',5,'CLSToggled()');
fade('combinedLayoutSelectorDiv',1,0,10);
sendData('CLSShow=0');
*/
dgi('CLSToggleIcon').src="<?php echo outIcon('down');?>"
}
}
// Request a combined layout change
function setCombinedLayout(nl){
var noTNUpdate;
if(nl==combinedLayout) return;
if(nl.substr(0,1)==combinedLayout.substr(0,1) && W.layoutSubLayoutChanged) {
if(layoutSubLayoutChanged(nl)) noTNUpdate=1;
}
combinedLayout=nl;
sendData('setCombinedLayout='+nl+((noTNUpdate)?'&filesListNoUpdate=1':''));
}
<?php
// Hidden fields
echo $preview->JSDefinition();
// Keyboard shortcuts
echo $preview->setKeyboardShortcuts();
?>
</script>
<?php
// Display page
require(cfAppDocRoot().'/res/explorer/Photo1/layout'.$_ENV['COMBINED_LAYOUTS'][cfRGetVar('combinedLayout')].'.php');
?>